<%@ page language="java"  pageEncoding="utf-8"%>
<%@page import="com.ejoysoft.wlanyz.business.ResultsShow"%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<%@ page import=" java.util.Vector,com.ejoysoft.wlanyz.business.WarnAppear,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("10035"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
%>
<%
    //初始化
    ResultsShow  resultsShow=null;
    ResultsShow obj=new ResultsShow(globa);
    //查询条件
    String  strCity=ParamUtil.getString(request,"strCity","").trim();
    String  strEndTime=ParamUtil.getString(request,"strEndTime","").trim();
    String  strStartTime=ParamUtil.getString(request,"strStartTime","").trim();
    String  checkedFlag = ParamUtil.getString(request,"checkedFlag","").trim();
    String  strIndicatorName=ParamUtil.getString(request,"strIndicatorName","").trim();
    String exportFlag = ParamUtil.getString(request,"exportFlag","");
	String exportContent = ParamUtil.getString(request,"exportContent","");
		//当前页
    int intCurPage = Integer.parseInt(ParamUtil.getString(request,"strCurPage","1"));
	String tWhere=" WHERE 1=1 and a.strnettype =  '"+checkedFlag+"'";//由于是左连接所以可以使用a.strnettype
    if(!strCity.equals("")){
     tWhere += " and b.strCity LIKE '%"+ strCity +"%' " ;
    }
	//记录总数
	int intAllCount=obj.getCount(tWhere,strStartTime,strEndTime);	

	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","15");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<ResultsShow> vctObj=obj.list(tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
    
	if(exportFlag.equals("exportResult"))
	{
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(tWhere,0,0,strStartTime,strEndTime);
		}
   	   	StringBuffer sb = new StringBuffer("<html><body><table  border=1>");
   	   	
	    sb.append("<tr><td>地市</td><td>区县 </td><td>网络类型 </td><td>小区名称 </td><td>小区区号</td><td>小区ＩＤ</td><td>任务类型</td><td>代维人员</td><td>测试手机号</td><td>测试时间</td><td>AP关联成功率</td>");
	    sb.append("<td>AP关联时延</td><td>PEAP认证成功率</td><td>PEAP下线成功率</td><td>PEAP认证时延</td><td>HTTP请求成功率</td><td>HTTP响应时延</td><td>PING成功率</td><td>PING平均时延</td><td>用户隔离成功率</td>");
	    sb.append("<td>用户漫游成功率</td><td>WEB认证时延</td><td>WEB认证成功率</td><td>WEB下线时延</td><td>WEB下线成功率</td><td>FTP上行速率</td><td>FTP下行速率</td><td>FTP上行成功率</td><td>FTP下行成功率</td></tr>");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       sb.append("<tr><td>"+(vctObj.get(i).getStrCity()==null?" ":vctObj.get(i).getStrCity()));
		       sb.append("</td><td>");
		       sb.append((vctObj.get(i).getStrTown()==null?" ":vctObj.get(i).getStrTown()));
		       sb.append( "</td><td>");
		       sb.append((vctObj.get(i).getStrNetType()==null?" ":vctObj.get(i).getStrNetType()));
		       sb.append( "</td><td>");
		       sb.append((vctObj.get(i).getStrSiteName()==null?" ":vctObj.get(i).getStrSiteName()));
		       sb.append( "</td><td>");
		       sb.append((vctObj.get(i).getStrLac()==null?" ":vctObj.get(i).getStrLac())); 
               sb.append("</td><td>");
               sb.append((vctObj.get(i).getStrCommunityId()==null?" ":vctObj.get(i).getStrCommunityId()));
               sb.append("</td><td>");
               sb.append((vctObj.get(i).getStrTaskType()==null?" ":vctObj.get(i).getStrTaskType()));
               sb.append( "</td><td>");
               sb.append((vctObj.get(i).getStrTaskMan()==null?" ":vctObj.get(i).getStrTaskMan()));
               sb.append( "</td><td>");
               sb.append((vctObj.get(i).getStrPhone()==null?" ":vctObj.get(i).getStrPhone()));
               sb.append( "</td><td>");
               sb.append((vctObj.get(i).getDtCreateDate()==null?" ":vctObj.get(i).getDtCreateDate()));
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTAP_RELEVACY_SUCRATE());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTAP_RELEVACY_DELAY());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTPEAP_AUTH_SUCRATE());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTPEAP_OFF_SUCRATE());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTPEAP_UP_DELAY());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTHTTP_REQ_SUCRATE()); 
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTHTTP_RESP_DELAY());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTPING_SUCRATE());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTPING_DELAY());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTUSER_SEG_SUCRATE());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTUSER_ROAM_SUCRATE());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTWEB_UP_DELAY());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTWEB_AUTH_SUCRATE());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTWEB_DOWN_DELAY());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTWEB_OFF_SUCRATE()); 
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTFTP_UP_SPEED());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTFTP_DOWN_SPEED()); 
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTFTP_UP_SUCRATE());
               sb.append("</td><td>");
               sb.append(vctObj.get(i).getINTFTP_DOWN_SUCRATE());
               sb.append("</td></tr>");
		    }
	    }
   	   	sb.append("</table></body></html>");
   	   	System.out.println(sb);
	    String strFileName = "测试原始结果查看表.xls";//自定义xls文件的文件名
	    response.setCharacterEncoding("utf-8");
	    response.setContentType("APPLICATION/*;charset=utf-8");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    System.out.println(sb.toString());
	    output.write(sb.toString().getBytes("utf-8"));
	  //out.clearBuffer(); 
	  //WarnAppear.shareMethodForExport(sb,strFileName,response,out,pageContext);
 
	} 
%>
<%@ include file="../include/jsp/footer.jsp"%>
